* compile in gpsbabel translations and map on non mac unix distributions by default.
This eliminates the need to install gpsbabelfe_*.qm, gpsbabel_*.qm and
gmapbase.html on the system.
Note that the Qt supplied translations must still be installed on the system.
The Qt translations may be in a package like qttranslations5-l10n or
qt5-qttranslations.
* simplify optional resources using std methods.
* discuss dependencies in INSTALL.
On macOS an app bundle will be created at gui/GPSBabelFE.app and an apple disk
image will be created at gui/GPSBabelFE.dmg.
+Dependencies:
+On non-macOS unix builds by default we now compile in the gpsbabel generated
+translation files, i.e. gpsbabelfe_*.qm, gpsbabel_*.qm, as well as
+gmapbase.html. When compiled in these files do not need to be distributed.
+These are used by the GUI. Additional translation files from Qt will also be
+used if they are found. They may be in a package such as qttranslations5-l10n
+or qt5-qttranslations.
+
Windows builds:
Two build methods are supported with MSVC tools.
1. "qmake -tp vc" will create a visual studio project that can be built with msbuild.
QT += webenginewidgets webchannel
DEFINES += HAVE_WEBENGINE
} else {
- QT += webkit webkitwidgets
+ QT += webkit webkitwidgets
}
unix:DESTDIR = objects
UI_DIR = tmp
-RESOURCES = app.qrc
+RESOURCES = app.qrc
RC_FILE = app.rc
-win32 {
+win32 {
TARGET=GPSBabelFE
}
win32-g++ {
TRANSLATIONS += gpsbabelfe_hu.ts
TRANSLATIONS += gpsbabelfe_it.ts
+unix:!mac {
+ !defined(EMBED_TRANSLATIONS, var):EMBED_TRANSLATIONS = on
+ !defined(EMBED_MAP, var):EMBED_MAP = on
+}
+equals(EMBED_TRANSLATIONS, on) {
+ RESOURCES += translations.qrc
+}
+equals(EMBED_MAP, on) {
+ RESOURCES += map.qrc
+}
+
macx|linux{
package.commands = QMAKE=$(QMAKE) ./package_app
package.depends = $(TARGET)
#include <QtCore/QEvent> // for QEvent (& QEvent::LanguageChange, QEvent::LocaleChange)
#include <QtCore/QFile> // for QFile
#include <QtCore/QFileInfo> // for QFileInfo
+#include <QtCore/QLibraryInfo> // for QLibraryInfo, QLibraryInfo::TranslationsPath
#include <QtCore/QLocale> // for QLocale
#include <QtCore/QMimeData> // for QMimeData
#include <QtCore/QProcess> // for QProcess, QProcess::NotRunning
#include <QtCore/QRegExp> // for QRegExp
#include <QtCore/QSettings> // for QSettings
+#include <QtCore/QString> // for QString
+#include <QtCore/QStringList> // for QStringList
#include <QtCore/QTemporaryFile> // for QTemporaryFile
#include <QtCore/QTime> // for QTime
#include <QtCore/QUrl> // for QUrl
ui_.outputWindow->setReadOnly(true);
- langPath_ = QApplication::applicationDirPath();
- langPath_.append("/translations/");
-
// Start up in the current system language.
loadLanguage(QLocale::system().name());
loadFormats();
// remove the old translator
qApp->removeTranslator(&translator);
- // load the new translator
- if (translator.load(filename, langPath_)) {
- qApp->installTranslator(&translator);
+ // Set a list of locations to search for the translation file.
+ // 1. In the file system in the translations directory relative to the
+ // location of the executable.
+ // 2. In the Qt resource system under the translations path. This is useful
+ // if the resource was compiled into the executable.
+ // 3. In the translations path for Qt. This is useful to find translations
+ // included with Qt.
+ const QStringList directories = {
+ QApplication::applicationDirPath() + "/translations",
+ ":/translations",
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath)
+ };
+
+ // Load the new translator.
+ for (const auto& directory : directories) {
+ if (translator.load(filename, directory)) {
+ qApp->installTranslator(&translator);
+ break;
+ }
}
}
QTranslator translatorCore_; // translation for the core application.
QTranslator translatorQt_; // translations for Qt.
QString currLang_; // currently loaded language.
- QString langPath_; // Absolute path of language files.
private:
void loadFormats();
connect(mclicker, SIGNAL(logTime(QString)), this, SLOT(logTime(QString)));
#endif
+ // We search the following locations:
+ // 1. In the file system in the same directory as the executable.
+ // 2. In the Qt resource system. This is useful if the resource was compiled
+ // into the executable.
QString baseFile = QApplication::applicationDirPath() + "/gmapbase.html";
- if (!QFile(baseFile).exists()) {
+ if (QFile(baseFile).exists()) {
+ this->load(QUrl::fromLocalFile(baseFile));
+ } else if (QFile(":/gmapbase.html").exists()) {
+ this->load(QUrl("qrc:///gmapbase.html"));
+ } else {
QMessageBox::critical(nullptr, appName,
tr("Missing \"gmapbase.html\" file. Check installation"));
- } else {
- QString urlStr = "file:///" + baseFile;
- this->load(QUrl(urlStr));
}
#ifdef DEBUG_JS_GENERATION
--- /dev/null
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file>gmapbase.html</file>
+ </qresource>
+ </RCC>
--- /dev/null
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file alias="translations/gpsbabel_de.qm">coretool/gpsbabel_de.qm</file>
+ <file alias="translations/gpsbabel_es.qm">coretool/gpsbabel_es.qm</file>
+ <file alias="translations/gpsbabel_fr.qm">coretool/gpsbabel_fr.qm</file>
+ <file alias="translations/gpsbabel_hu.qm">coretool/gpsbabel_hu.qm</file>
+ <file alias="translations/gpsbabel_it.qm">coretool/gpsbabel_it.qm</file>
+ <file alias="translations/gpsbabel_ru.qm">coretool/gpsbabel_ru.qm</file>
+ <file alias="translations/gpsbabelfe_de.qm">gpsbabelfe_de.qm</file>
+ <file alias="translations/gpsbabelfe_es.qm">gpsbabelfe_es.qm</file>
+ <file alias="translations/gpsbabelfe_fr.qm">gpsbabelfe_fr.qm</file>
+ <file alias="translations/gpsbabelfe_hu.qm">gpsbabelfe_hu.qm</file>
+ <file alias="translations/gpsbabelfe_it.qm">gpsbabelfe_it.qm</file>
+ <file alias="translations/gpsbabelfe_ru.qm">gpsbabelfe_ru.qm</file>
+ </qresource>
+ </RCC>